<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 200px;
            height: 200px;
            border: 1px solid pink;
            margin: 100px auto;

            /* 这一步很重要 */
            overflow: hidden;
        }
        div::before{
            display: block;
            content: 'demo';
            width: 100%;
            height: 100%;
            background-color: hotpink;
            transform-origin: left bottom;
            transform: rotate(90deg);
            transition: all 0.5s linear;
        }
        div:hover::before{
            transform: rotate(0deg);
        }
    </style>
</head>
<body>
    <div class="parent">
        鼠标放上来试试
    </div>
</body>
</html>